using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace ExtendedControls
{
  public class ExtendedListViewItem : ListViewItem
  {
		internal enum DepthMarks
		{
			DownPipe,
			Elbow,
			None
		}


		private ExtendedVirtualViewItem virtualItem;

		private ExtendedVirtualViewItem parentItem;
		private int _depth;
		private ExtendedListView _extendedListView;
		internal List<DepthMarks> DepthMarkers;

		public int Ordinal;
		public int ChildCount;

    
    public ExtendedListViewItem():base() {
      Children = new ExtendedListView.ExtendedListViewItemCollection(this.ExtendedListView,this);
			DepthMarkers = new List<DepthMarks>();
		}

		public ExtendedListViewItem(string[] items)
			: base(items)
		{
			Children = new ExtendedListView.ExtendedListViewItemCollection(this.ExtendedListView, this);
			DepthMarkers = new List<DepthMarks>();
		}


    public ExtendedListView.ExtendedListViewItemCollection Children;

    public ExtendedVirtualViewItem ParentItem {
      get { return parentItem; }
      internal set { parentItem=value; }
    }

		public ExtendedVirtualViewItem VirtualItem
		{
			get { return virtualItem; }
			internal set { virtualItem = value; }
		}

    public bool Visible {
      get {
        if (parentItem==null) {
          return true;
        }
        return (parentItem.Visible & parentItem.IsExpanded);
      }
    }

    public ExtendedListView ExtendedListView {
      get { return _extendedListView; }
      internal set { _extendedListView = value; }
    }


    public int Depth {
      get { return _depth; }
      internal set { _depth = value; }
    }

    bool _isExpanded = false;
    
    public bool IsExpanded {
      get { return _isExpanded; }
      internal set { _isExpanded = value; }
    }

		private string secondaryImageKey=null;

		public string SecondaryImageKey
		{
			get { return secondaryImageKey; }
			set { secondaryImageKey = value; }
		}

		private int secondaryImageIndex=-1;

		public int SecondaryImageIndex
		{
			get { return secondaryImageIndex; }
			set { secondaryImageIndex = value; }
		}

		private bool hasCheckbox=false;

		public bool HasCheckbox
		{
			get { return hasCheckbox; }
			set { hasCheckbox = value; }
		}

		public bool IsLastChild
		{
			get
			{
				if (this.virtualItem != null && this.parentItem != null)
					return this.virtualItem == this.ParentItem.Children.Last;
				else
					return this == this.ListView.Items[ListView.Items.Count - 1];
			}
		}

		

  }
}
